/*
 * SatPrioritizer.cpp
 *
 *  Created on: Oct 11, 2014
 *      Authors: Avihay Avitan & Stefan Farcas
 */

#include "PassPrioritizer.h"

namespace PassPrioritizerNameSpace {
/**
 * initiate pass prioritize object
 */
PassPrioritizer::PassPrioritizer()
{
	logger = Logger::getGSLogger();
}

PassPrioritizer::~PassPrioritizer()
{
	delete(logger);
	while (!pq.empty())
	{
		PassVector * todel = getNext();
		pq.pop();
		delete(todel);
	}
}

/**
 * returning the next PassVector- the satellite that should be served next
 */
PassVector * PassPrioritizer::getNext() {
	PassVector * top = this->pq.top();
	this->pq.pop();
	return top;
}
/**
 * returns true if there is another satellite to serve
 */
bool PassPrioritizer::hasNext() {
	return !this->pq.empty();
}
/**
 * returns the number of PassVector in the queue
 */
int PassPrioritizer::getCount() {
	return this->pq.size();
}

/**
 * adding a new PassVector to the queue
 */
void PassPrioritizer::add(PassVector * satellite) {
	if (satellite != NULL)
		this->pq.push(satellite);
	else
	{
		ProgressStatus status(ProgressStatusType::ERR, "[PassPrioritizer]", "add" , OBJECT_IS_NULL, true, false);
		logger->logError(status);
	}}

} /* namespace SatPrioritizerNameSpace */
